package com.yhb.channel.model;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.yhb.channel.model.BankCard;
import com.yhb.channel.model.IBankCard;
import com.yhb.channel.utils.ChannelJSONUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.HashMap;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class TryPayPayload {
    String userId;

    IBankCard payCard;
    IBankCard remitCard;

    BigDecimal orderAmount;
    BigDecimal userFeeAmount;
    String bindCardUUID;
    String clientIP;
    String payRate;

    String province;
    String city;
    String area;

    String payExecutionFlowId;

    @JsonSetter("payCard")
    public void setPayCard(HashMap payCard) {
        this.payCard = ChannelJSONUtil.parseJson(payCard, BankCard.class);
    }

    @JsonSetter("remitCard")
    public void setRemitCard(HashMap payCard) {
        this.remitCard = ChannelJSONUtil.parseJson(payCard, BankCard.class);
    }
}
